
<?php
function loadFiles($dir) {
   $files = array();
   $handle = opendir($dir);
   if (!$handle) die('Kan inte lista filer i' . $dir);
   while (false !== ($file = readdir($handle))) {
      if ($file != "." && $file != "..") {
         $file_8859 = iconv( "utf-8", "iso-8859-1", $file );
         $modified = filemtime($dir . $file);
         $files[] = array($file_8859, $modified);
      }
   }
   closedir($handle);

   return $files;
}

function dateCmp($a, $b) {
   return ($a[1] > $b[1]) ? -1 : 1;
}

function sortDates(&$files) {
   usort($files, 'dateCmp');
}

function printFiles(&$files, $dir) {

   echo "<br>";
   echo "<table border=\"0\">";
   echo "<tr>";
   echo "<td width=\"70%\" valign=\"top\">";

foreach($files as $f) {
   echo "<p>";
   echo "<img src=\"../img/link.gif\" width=\"7\" height=\"11\" />&nbsp;<a href=\"$dir/$f[0]\">$f[0]</a>";
   echo "</p>";
}
   echo "</td>";
   echo "</tr>";
   echo "</table>";

}


function printMembers(&$files, $dir) {

   echo "<table cellspacing=\"10\" width=\"100%\">";
	echo "<td colspan=\"2\">";	
	echo "<hr>";
	echo "</td>";
   foreach($files as $f) {
	echo "<tr>";
	$file_2 = utf8_encode("$dir/$f[0]/text.txt");
	$text = utf8_decode(file_get_contents($file_2));
	echo "<td><img src=\"$dir/$f[0]/bild.jpg\" width=\"240\" /></td>";
	echo "<td style=\"vertical-align:top;\"><b>$f[0]</b></br>$text</td>";
	echo "</tr>";
	echo "<tr>";
	echo "<td colspan=\"2\">";
	echo "<hr>";
	echo "</td>";
	echo "</tr>";
   }
   echo "</table>";

}


function printMediaFiles(&$mfiles, $dir, $dirsmall) {

   echo "<br>";
   echo "<table border=\"1\">";
   echo "<tr>";
   echo "<td width=\"70%\" valign=\"top\">";

foreach($mfiles as $mf) {
   echo "<p>";
   echo "<a href=\"$dir/$mf[0]\">$mf[0]</a> &nbsp;<img src=\"$dirsmall/$mf[0]\"/> <br>";
   echo "</p>";
}
   echo "</td>";
   echo "</tr>";
   echo "</table>";

}

?>

